package com.cszy.yydqbfq.adapter

import android.content.Context
import android.graphics.Color
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.cszy.yydqbfq.R
import com.hjq.shape.layout.ShapeConstraintLayout


import com.lzx.starrysky.SongInfo

class SongDeailPopAdapter : BaseQuickAdapter<SongInfo, QuickViewHolder>() {

    private val selectColor by lazy {
        context.getColor(R.color.select_color)
    }

    private val normalTitleColor by lazy {
        context.getColor(R.color.title_color)
    }

    private val normalAuthorColor by lazy {
        context.getColor(R.color.sub_title_color)
    }


    private var selectPosition: Int = -1;
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: SongInfo?) {
        holder.setText(R.id.tv_music_name, item?.songName)
        holder.setText(R.id.tv_music_author, item?.artist)
        if (selectPosition == position) {
            holder.getView<TextView>(R.id.tv_music_name).setTextColor(selectColor)
            holder.getView<TextView>(R.id.tv_music_author).setTextColor(selectColor)
            holder.getView<ImageView>(R.id.iv_music_img).setImageResource(R.mipmap.ic_bofang_pause)
        } else {
            holder.getView<TextView>(R.id.tv_music_name).setTextColor(normalTitleColor)
            holder.getView<TextView>(R.id.tv_music_author).setTextColor(normalAuthorColor)
            holder.getView<ImageView>(R.id.iv_music_img).setImageResource(R.mipmap.ic_bofang_pop)
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_pop_list, parent)
    }

    fun setPosition(position: Int) {
        this.selectPosition = position;
        notifyDataSetChanged()
    }
}